<template>
  <div class="kpiReport">
    <div class="query-container">
      <el-form inline label-width="90px">
        <div style="width:74%;float:left;">
          <el-form-item label="考核月份">
            <sorting-selector
              :widths="1"
              :isDisabled="loading"
              :select-value.sync="particularYear"
              :options="options.yearOptions"
            ></sorting-selector>
            <sorting-selector
              :widths="2"
              :isDisabled="loading"
              :select-value.sync="particularMonth"
              :options="options.monthOptions"
              :is-disabled="!particularYear"
            ></sorting-selector>
          </el-form-item>
          <el-form-item label="承运方">
            <el-select v-model="params.supplierCompanyId" placeholder="请选择" style="width: 226px" @change="carrierChange" clearable>
              <el-option
                v-for="(item,index) in options.supplierOptions"
                :key="index"
                :label="item.name"
                :value="item.supplierCompanyId">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="业务类型">
            <el-select v-model="params.topType" placeholder="请选择" style="width: 226px" @change="topType" clearable>
              <el-option
                v-for="item in options.workOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="CDC仓库" v-if="params.topType == 2 || params.topType == 3 || params.topType == 4">
            <el-select v-model="params.topWarehouseShortName" style="width: 226px" placeholder="请选择" clearable>
              <el-option
                v-for="item in options.CDCwarehouse"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="OEM供应商" v-if="params.topType == 1">
            <el-select v-model="params.oemGysCode" style="width: 226px" placeholder="请选择" clearable>
              <el-option
                v-for="(item,index) in options.OEMOptions"
                :key="index"
                :label="item.name"
                :value="item.oemGysCode">
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div style="width:440px;float:right">
          <el-form-item style="float: right">
            <el-button type="primary"
                      icon="el-icon-search"
                      :disabled="loading"
                      :loading="loading"
                      @click="search(1)">考核</el-button>
            <el-button type="primary"
                      icon="el-icon-refresh"
                      @click="resetForm">重置</el-button>
            <el-button type="primary"
                      icon="el-icon-refresh"
                      :disabled="loading"
                      :loading="loading"
                      @click="refreshOpen">重算考核数据</el-button>
            <el-button v-if="resultObj.uuId"
                      icon="el-icon-document"
                      type="primary"
                      @click="detail">明细</el-button>
          </el-form-item>
        </div>
      </el-form>
    </div>
      <div class="box-card orderQuery">
        <p style="color: red;margin: 0;padding:10px 0;">操作说明:考核的月份数据，如果是当天操作的签收、回单等操作；或是本公司的送货时效、回单时效设置做了变更；为了保证数据准确性，需要操作"重算考核数据"再进行"考核"。</p>
          <!-- <div class="kpi-title">{{params.sendGoodsStartTime?`${$tools.formatData(params.sendGoodsStartTime,'')}-`:''}}{{params.sendGoodsEndTime?$tools.formatData(params.sendGoodsEndTime,''):''}}{{supplierName}}{{orderTypesName}}KPI考核汇总表</div> -->
          <div class="kpi-title">脱普公司物流服务KPI考核评分表</div>
          <div class="year-title" v-if="titleYear && titleMonth">{{ titleYear }}-{{ titleMonth }}</div>
          <el-form style="width:10%;height:60px;position: absolute;top:20px;right:20px;">
            <el-form-item style="float: right">
              <el-button type="default"
                        icon="el-icon-s-promotion"
                        @click="handleExport">导出</el-button>
            </el-form-item>
          </el-form>
          <el-row :gutter="20" style="padding: 8px 0;" v-show="showTitle">
            <el-col :span="8" style="text-align: left"
              >承运方：{{ supplierName  }}</el-col
            >
            <el-col :span="shortName?4:(topGysName?4:8)" style="text-align: center"
              >业务类型：{{ orderTypesName01 }}</el-col
            >
            <el-col :span="4" style="text-align: center">
              <span
                v-if="
                  (params.topType == 2 || params.topType == 3) &&
                    params.topWarehouseShortName != '' &&
                    params.topWarehouseShortName != undefined &&
                    haveData01
                "
                >CDC仓库：{{ shortName }}</span
              >
              <span
                v-if="
                  params.topType == 1 &&
                    params.oemGysName != '' &&
                    params.oemGysName != undefined &&
                    haveData02
                "
                >OEM供应商：{{ topGysName }}</span
              >
            </el-col>
            <el-col :span="8" style="text-align: right">
              考核时间：{{ kpiStatisticsDate }}</el-col
            >
          </el-row>
          <el-table
            class="table-container"
            height="90%"
            :data="tableData"
            border
            size="small"
            :span-method="objectSpanMethod"
            v-loading="loading"
          >
            <el-table-column prop="work" label="项目" align="center" width="200px">
            </el-table-column>
            <el-table-column align="center" label="明细" display="inline-block !important">
              <el-table-column
                label="分项"
                prop="subOption"
                width="120px"
                align="center"
              ></el-table-column>
              <el-table-column
                label="分项描述"
                width="180px"
                prop="description"
              ></el-table-column>
            </el-table-column>
            <el-table-column
              prop="standard"
              label="达成标准"
              width="120px"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="calculation"
              label="计算公式"
            ></el-table-column>
            <el-table-column
              prop="proportion"
              label="占比"
              width="100px"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="fullScore"
              label="满分"
              width="100px"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="actual"
              label="实际达成"
              width="120px"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="score"
              label="得分"
              width="100px"
              align="center"
            ></el-table-column>
          </el-table>
        </div>
        <el-dialog
          :title="kpiTitle"
          :visible.sync="dialogShow"
          width="30%"
          :before-close="handleShow">
          <div>
            <div class="reminderLeft">
              <span class="el-icon-warning"></span>
            </div>
            <div class="reminderRight">
              <span style="color:var(--prev-color-primary)">{{dialogText}}</span>
            </div>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="dialogShow = false">我知道了</el-button>
          </span>
        </el-dialog>
    </div>
</template>

<script src="./rmsJs/KpiReport.js"></script>

<style scoped>
.table-container >>> .el-table__body-wrapper {
  height: 82% !important;
  overflow-y: auto;
}
.orderQuery >>> .el-pagination {
  margin-top: 20px;
  /* text-align: right; */
}
.orderQuery >>> .el-table tr {
  background-color: var(--prev-bg-white);
  height: 50px;
  font-size: 14px;
}
.orderQuery >>> .el-card__body {
  
}
.orderQuery {
  position: relative;
  height: 100%;
  margin-top: 20px;
}

.kpiReport >>> .el-table th.el-table__cell.is-leaf,
.el-table td.el-table__cell {
  border-bottom: 1px solid var(--prev-border-color-lighter);
  font-size: 14px;
  font-family: PingFang SC;
  font-weight: normal;
  line-height: 20px;
  color: #333333;
  opacity: 1;
}

.kpiReport >>> .el-table .el-table_2_column_12 .cell
 {
  font-weight: normal;
  display: inline-block !important;
}

.kpiReport >>> .el-table .el-table_1_column_2 .cell
 {
  font-weight: normal;
  display: inline-block !important;
}
</style>
<style lang="scss" scoped>
.kpiReport {
  width: 100%;
  height: 100%;
  .query-container {
    padding: 20px 20px 0 0;
    background: var(--prev-bg-white);
    box-shadow: 0px 3px 6px rgba(35, 35, 35, 0.16);
    overflow: hidden;
  }
  .kpi-title {
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    padding-bottom: 10px;
  }
  .year-title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
  }
  .orderQuery {
    padding: 20px;
    margin-top: 12px;
    background: var(--prev-bg-white);
    height: calc(100vh - 170px);
    box-shadow: 0px 3px 6px rgba(35, 35, 35, 0.16);
    .table-container {
      height: 100%;
      .target-power {
        display: flex;
        .power {
          display: flex;
          align-items: center;
        }
      }
    }
  }
}
.reminderLeft {
  width: 44px;
  height: 44px;
  font-size: 36px;
  color: #eb662b;
  float: left;
  display: inline-block;
}
.reminderRight {
  width: 450px;
  float: left;
  padding: 4px 0 10px 0;
  display: inline-block;
}
</style>
<style>
.reminder {
  width: 526px;
}
</style>
